# !/usr/bin/env python
# coding=utf-8
# @Time    : 2019/9/11 17:35
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/SeleniumCrapy.git
# @File    : my_excel.py
# @Software: PyCharm
# @Version: 2.7.5
import xlrd


def rows2list(file):
	x1 = xlrd.open_workbook(file)
	sheet1 = x1.sheet_by_name("Sheet1")
	# 单元格批量读取
	# print(sheet1.row_values(0))  # 获取第一行所有内容，合并单元格，首行显示值，其它为空。
	# print(sheet1.row(0))         # 获取单元格值类型和内容
	# print(sheet1.row_types(0))   # 获取单元格数据类型
	owner_list = []
	key_list = sheet1.row_values(0)
	# print(sheet1.get_rows())
	for index1, row in enumerate(sheet1.get_rows()):
		if index1==0:
			continue
		row_dict = {}
		for index2, item in enumerate(row):
			if type(item.value) == str:
				row_dict[key_list[index2]] = item.value.replace(' text', '')
			else:
				row_dict[key_list[index2]] = item.value
		owner_list.append(row_dict)
	return owner_list




# if __name__ == '__main__':
# 	from py3_utils import my_path
# 	print(rows2list(my_path.make_path(['..\\','owner_data','7月人保-国续.xlsx'])))